'use strict';

const user = require("./user");

module.exports = app => {
    const {
        STRING,
        INTEGER
    } = app.Sequelize;

    const Info = app.model.define('info', {
        id: {
            type: INTEGER,
            primaryKey: true,
            autoIncrement: true
        },
        user_id: INTEGER,
        nickname: STRING(20),
        introduction: STRING(200),
        img_url: STRING(500),
    });

    Info.associate = function () {
        app.model.Info.belongsTo(app.model.User, {
            foreignKey: 'user_id',
            targetKey: 'id'
        });

        app.model.Info.hasMany(app.model.Video, {
            foreignKey: 'publisher_id'
        });

        app.model.Info.hasMany(app.model.Dynamic, {
            foreignKey: 'post_uid'
        });
    }

    return Info;
};